package com.simba.server.jsonservice.serivces;

import org.apache.log4j.Logger;
import org.jboss.netty.channel.Channel;
import com.simba.common.jsonservice.JsonService;
import com.simba.common.log.LogUtil;
import com.simba.server.components.SlotManager;
import com.simba.server.components.data.SlotInfo;

public class RenewAllBoxInfos implements JsonService
{
	public static final String NAME = "RenewAllBoxInfo";
	private final static Logger logger = Logger.getLogger(RenewAllBoxInfos.class);

	@Override
	public void handleRequest(Channel channel, Object content)
	{
		try
		{
			SlotInfo[] slotInfos = SlotManager.getInstance().getSlotInfoList();
			for (SlotInfo slotInfo : slotInfos)
			{
				slotInfo.resetBoxInfo();
				SlotManager.getInstance().doAllocBoxInfo(slotInfo);
			}
			SlotManager.getInstance().renewSlotInfo();
		}
		catch (Exception e)
		{
			LogUtil.LogError(RenewAllBoxInfos.logger,
					"Renew All Box Info Json Service Error : exception info : ");
		}
	}
}
